package cn.edu.hubu.hubusmartzoohouse.controller;

import cn.edu.hubu.hubusmartzoohouse.entity.User;
import cn.edu.hubu.hubusmartzoohouse.service.UserService;
import cn.edu.hubu.hubusmartzoohouse.vo.ResultVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@CrossOrigin
public class UserController {

    @Autowired
    private UserService userService;

    @RequestMapping("/user/check")
    public ResultVo check(String account) {
        //调用UserService中的checkAccount业务方法进行验证
        ResultVo vo = userService.checkAccount(account);
        return vo;
    }

    @RequestMapping("/user/regist")
    public ResultVo regist(User user) {
        //System.out.println("regist");
        ResultVo vo = userService.saveUser(user);
        return vo;
    }

    @RequestMapping("/user/login")
    public ResultVo login(String account, String pwd) {
        ResultVo vo = userService.checkLogin(account, pwd);
        return vo;
    }

}
